public class test {
    //数组转字符串
    public static String myTostring(int[] array){
        String ret = "[";
        for (int i = 0; i <array.length ; i++) {
            ret += array[i];
            if(i != array.length - 1) {
                ret += ",";
            }
        }
        ret += "]";
        return ret;
    }
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5};
        String ret = myTostring(array);
        System.out.println(ret);
    }
    public static void func(){
        int[] array1 = new int[3];
        array1[0] = 10;
        array1[1] = 20;
        array1[3] = 30;
        int[] array2 = new int[]{1,2,3,4,5};
        array2[0] = 100;
        array2[1] = 200;
        array1 = array2;//array1这个引用类型指向array2这个引用类型所指向的对象,存的是地址
        array1[2] = 300;
        array1[3] = 400;
        array2[4] = 500;
        for (int i = 0; i < array2.length; i++) {
            System.out.println(array2[i]);
        }
    }
    public static void main3(String[] args) {
        int a = 10;
        int b = 20;
        int[] array3={1,2,3,4};//array为引用数据类型，因为其存的是地址； 引用指向对象；
        int[] array4 = null;//代表array4这个引用不指向任何对象；
    }
    public static void main2(String[] args) {
        int[] array2 = {1,2,3,4,5,6};//静态数组初始化可以简写；
        System.out.println(array2[0]);
        array2[0]= 100;
        System.out.println(array2[0]);
    }
    public static void main1(String[] args) {
        int[] array = new int[10];
        System.out.println(array[0]);
    }
}
